package pers.fulsun.es.test._02_index;

import java.io.IOException;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import pers.fulsun.es.test._01_ESClient;

public class _01_ESTest_Index_Create {
  private static RestHighLevelClient client= _01_ESClient.getClient();;

  public static void main(String[] args) throws IOException {
    // 创建索引 - 请求对象
    CreateIndexRequest request = new CreateIndexRequest("user1");
    // 发送请求，获取响应
    CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT);
    boolean acknowledged = response.isAcknowledged();
    // 响应状态
    System.out.println("操作状态 = " + acknowledged);
    // 关闭客户端连接
    client.close();
  }
}
